<?php TPL::output('admin/global/header.tpl.htm'); ?>
<script type="text/javascript" src="<?php echo G_STATIC_URL; ?>/admin/js/admin_fileupload.js?v=<?php echo G_VERSION_BUILD; ?>" ></script>
<script type="text/javascript" charset="utf-8" src="<?php echo G_STATIC_URL; ?>/admin/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo G_STATIC_URL; ?>/admin/js/ueditor/ueditor.all.js"> </script>
<?php TPL::output('admin/global/nav_menu.tpl.htm'); ?>
<style>
    .aw-upload-box .upload-list{width:694px;height: auto;overflow: hidden;}
    .aw-upload-box .upload-list li{position:relative;float: left;width: 216px;height: 115px;padding:15px 15px 15px 110px;margin:15px 15px 0 0;background: #F5F8FA;border:1px solid #dcedfa;border-radius: 5px;}
    .aw-upload-box .upload-list li .img{position:absolute;left:10px;top:10px;width: 90px;height: 90px;background: url('/static/common/ajax-loader.gif') center center no-repeat;text-align: center;line-height: 90px;border-radius: 5px;}
    .aw-upload-box .upload-list li .img.error, .aw-upload-box .upload-list li .img.file{background: none;}
    .aw-upload-box .upload-list li .img .icon-file{font-size: 48px;vertical-align: middle;color: #aac6e1;}
    .aw-upload-box .upload-list li .img .icon-delete{font-size: 24px;color: #ff6464;vertical-align: middle;}
    .aw-upload-box .upload-list li .content p{margin:0;line-height: 16px;}
    .aw-upload-box .upload-list li .title{height: 34px;overflow:hidden;word-wrap:break-word;font-size:12px;color: #666;}
    .aw-upload-box .upload-list li .size{margin-bottom:10px !important;font-size: 12px;color: #999;}
    .aw-upload-box .upload-list li .meta a{margin-right:5px;font-size: 13px;}
    .aw-upload-box .upload-list li.error{border-color: #ff6464;}
    .aw-upload-box .upload-list li.error .size{color: #ff6464;}
</style>
<div class="aw-content-wrap">
    <div class="mod">
        <div class="mod-head">
            <h3>
                <span class="pull-left"><?php _e('编辑商品资料'); ?></span>
            </h3>
        </div>
        <div class="mod-head">

            <ul class="nav nav-tabs">
                <li <?php if (!$_GET['type']) { ?> class="active"<?php } ?>><a href="<?php if ($_GET['type']) { ?>admin/goods/goods_list/<?php } else { ?>#list<?php } ?>"<?php if (!$_GET['type']) { ?> data-toggle="tab"<?php } ?>><?php _e('基础'); ?></a></li>
                <li><a href="#goods_style" data-toggle="tab"><?php _e('型号'); ?></a></li>

            </ul>
        </div>

     <div class="tab-content mod-content">
         <div class="tab-pane active" id="list">

                <form action="admin/goods_ajax/save_goods/" id="settings_form" enctype="multipart/form-data" method="post" onsubmit="return false">
                <table class="table table-striped">
                    <input type="hidden" name="goods_id"  id="goods_id" value="<?php echo $this->goods['goods_id']; ?>" />
                    <input type="hidden" name="attach_access_key" value="<?php echo $this->attach_access_key; ?>" />
                    <!---->
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('商品分类'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <select name="cat_id" class="form-control pull-left input-small">
                                        <option value="0"><?php _e('无'); ?></option>
                                        <?php echo $this->category_list; ?>
                                    </select>
                                    <!--<input class="form-control" name="cat_id" type="text" value="<?php echo $this->goods['cat_id']; ?>" />-->
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('京东链接'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="jd_url" type="text" value="<?php echo $this->goods['jd_url']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                    <td>
                        <div class="form-group">
                            <span class="col-sm-4 col-xs-3 control-label"><?php _e('淘宝链接'); ?>:</span>
                            <div class="col-sm-5 col-xs-8">
                                <input class="form-control" name="tb_url" type="text" value="<?php echo $this->goods['tb_url']; ?>" />
                            </div>
                        </div>
                    </td>
                </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('商品名'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="goods_name" type="text" value="<?php echo $this->goods['goods_name']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('商品编码'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="goods_sn" type="text" value="<?php echo $this->goods['goods_sn']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('关键字'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="keywords" type="text" value="<?php echo $this->goods['keywords']; ?>" />

                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('市场价格'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="market_price" type="text" value="<?php echo $this->goods['market_price']; ?>" />

                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('本店价格'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="shop_price" type="text" value="<?php echo $this->goods['shop_price']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('促销价格'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="promote_price" type="text" value="<?php echo $this->goods['promote_price']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('商品可获积分'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="give_integral" type="text" value="<?php echo $this->goods['give_integral']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('排序'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="sort_order" type="text" value="<?php echo $this->goods['sort_order']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('是否开放销售'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_on_sale" value="1"<?php if ($this->goods['is_on_sale'] == 1) { ?> checked="checked"<?php } ?> /> <?php _e('是'); ?>
                                        </label>

                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_on_sale" value="0"<?php if ($this->goods['is_on_sale'] == 0) { ?> checked="checked"<?php } ?> /> <?php _e('否'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('是否新品'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_new" value="1"<?php if ($this->goods['is_new'] == 1) { ?> checked="checked"<?php } ?> /> <?php _e('是'); ?>
                                        </label>

                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_new" value="0"<?php if ($this->goods['is_new'] == 0) { ?> checked="checked"<?php } ?> /> <?php _e('否'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('是否精品'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_best" value="1"<?php if ($this->goods['is_best'] == 1) { ?> checked="checked"<?php } ?> /> <?php _e('是'); ?>
                                        </label>

                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_best" value="0"<?php if ($this->goods['is_best'] == 0) { ?> checked="checked"<?php } ?> /> <?php _e('否'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('是否热销'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_hot" value="1"<?php if ($this->goods['is_hot'] == 1) { ?> checked="checked"<?php } ?> /> <?php _e('是'); ?>
                                        </label>

                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_hot" value="0"<?php if ($this->goods['is_hot'] == 0) { ?> checked="checked"<?php } ?> /> <?php _e('否'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('是否促销'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_promote" value="1"<?php if ($this->goods['is_promote'] == 1) { ?> checked="checked"<?php } ?> /> <?php _e('是'); ?>
                                        </label>

                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="is_promote" value="0"<?php if ($this->goods['is_promote'] == 0) { ?> checked="checked"<?php } ?> /> <?php _e('否'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('商品图册'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">

                                    <div class="aw-upload-box">
                                        <a class="btn btn-default goods_photos_uploads">上传图片</a>
                                        <div class="upload-container"><ul class="upload-list"></ul></div>
                                        <span class="text-color-999 aw-upload-tips hidden-xs">允许 : jpg,jpeg,png,gif</span>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <div class="col-sm-12 col-xs-8 ">
                                    <div class="aw-upload-box">
                                        <div class="upload-container"><ul class="upload-list photos-container"></ul></div>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('商品简短描述'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <textarea class="form-control" name="goods_brief" rows="3"><?php echo $this->goods['goods_brief']; ?></textarea>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-9 col-xs-3 control-label"><?php _e('商品简介'); ?>:</span>

                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <div class="col-sm-12 ">
                                    <textarea id="editor" name="goods_desc" style='min-height:500px;width: 100%'><?php echo $this->goods['goods_desc']; ?></textarea>
                                </div>
                            </div>
                        </td>
                    </tr>



                <tfoot>
                <tr>
                    <td>
                        <input id="goodsPost" type="button" value="<?php _e('保存设置'); ?>" class="btn btn-primary center-block"  />
                    </td>
                </tr>
                </tfoot>
            </table>
            </form>
         </div>
         <!--商品规格-->
        <div class="tab-pane" id="goods_style">
            <div class="hidden">
            <form  id="goodStyleCloneTpl" class="js-goods-style-form" action="admin/goods_ajax/save_goods_style/" enctype="multipart/form-data" method="post" onsubmit="return false">
                <input type="hidden" name="goods_id" value="<?php echo $this->goods['goods_id'];?>" />
                <input type="hidden" name="style_id" value="" />
                <table class=" table table-striped">
                <tr>
                        <td>
                            <input type="hidden" name="goods_color_name" value="<?php echo $val['goods_color_name']?>"/>
                            <select name="goods_color" class=" js-goods-color-choose form-control pull-left input-small">
                                <?php foreach($this->goods_color AS $color_key=>$color_val){ ?>
                                <option value="<?php echo $color_key;?>" data-name="<?php echo $color_val;?>" <?php if($color_key==$val['goods_color']){?> selected<?php }?>><?php echo $color_val; ?></option>
                                <?php } ?>
                            </select>
                        </td>

                        <td> <input class="form-control" value="<?php echo $val['goods_model'];?>" name="goods_model" placeholder="商品型号"></td>

                        <td>
                            <div style="width: 90px;">
                                <img src="<?php echo get_goods_cover_url($this->goods['goods_id'],'square',$val['goods_color_pic']); ?>" style="width: 100%"/>
                            </div>
                            <span class="mod-file">
                                        <input type="button" class="btn btn-primary" value="点击更换图片">
                                        <input type="file" name="goods_color_pic" exts="png|jpg|bmp|jpeg" class="mod-input-file">
                                </span>
                            <br>
                        </td>
                        <td> <input class="form-control" value="<?php echo $val['goods_total'];?>" name="goods_total" placeholder="数量"></td>
                        <td>
                            <a class="btn btn-primary  js-goods-style-submit"><?php _e('保存'); ?></a>
                        </td>
                </tr>
                </table>
            </form>
            </div>
                <div id="goodsModelTable">

                    <table class="table table-striped" id="">
                        <tr>
                            <td class="">
                                颜色值

                            </td>
                            <td> 商品型号</td>
                            <td>图片</td>
                            <td>总数</td>
                            <td>操作</td>
                        </tr>

                    </table>

                    <?php foreach($this->goods_style_list as $key=>$val ){ ?>
                    <form class="js-goods-style-form" action="admin/goods_ajax/save_goods_style/" enctype="multipart/form-data" method="post" onsubmit="return false">
                        <input type="hidden" name="goods_id" value="<?php echo $this->goods['goods_id'];?>" />
                        <input type="hidden" name="style_id" value="<?php echo $val['id'];?>" />
                        <table class="table table-striped">
                         <tr>
                            <td>
                                <input type="hidden" name="goods_color_name" value="<?php echo $val['goods_color_name']?>"/>
                                <select name="goods_color" class=" js-goods-color-choose form-control pull-left input-small">
                                    <?php foreach($this->goods_color AS $color_key=>$color_val){ ?>
                                         <option value="<?php echo $color_key;?>" data-name="<?php echo $color_val;?>" <?php if($color_key==$val['goods_color']){?> selected<?php }?>><?php echo $color_val; ?></option>
                                    <?php } ?>
                                </select>
                            </td>
                            <td> <input class="form-control" value="<?php echo $val['goods_model'];?>" name="goods_model" placeholder="商品型号"></td>
                            <td>
                                <div style="width: 90px;">
                                <img src="<?php echo get_goods_cover_url($this->goods['goods_id'],'square',$val['goods_color_pic']); ?>" style="width: 100%"/>
                                </div>
                                <span class="mod-file">
                                        <input type="button" class="btn btn-primary" value="点击更换图片">
                                        <input type="file" name="goods_color_pic" exts="png|jpg|bmp|jpeg" class="mod-input-file">
                                </span>
                                <br>
                            </td>
                            <td> <input class="form-control" value="<?php echo $val['goods_total'];?>" name="goods_total" placeholder="数量"></td>
                            <td>
                                <a class="btn btn-primary js-goods-style-submit" ><?php _e('保存'); ?></a>
                            </td>

                    </tr>
                </table>
                     </form>

                    <?php } ?>
                </div>
            <!--end / form 表单-->
            <div class="mod-table-foot">
                <div class="col-sm-4 col-xs-12">
                    <!--<a class="btn btn-danger" onclic k="AWS.ajax_post($('#users_form'));"><?php _e('删除'); ?></a>-->

                    <a class="btn btn-primary" id="goodsStyleAdd"><?php _e('新增'); ?></a>


                </div>
                <div class="col-xs-12 col-sm-8">
                    <?php echo $this->pagination; ?>
                </div>
            </div>
        </div>
         <!--end 型号-->
     </div>
    </div>
</div>

<script type="text/javascript">
    var ATTACH_ACCESS_KEY='<?php echo $this->attach_access_key; ?>';
    var PUBLISH_TYPE = 'goods';

$(document).ready(function () {

    var ue = UE.getEditor('editor');

});
</script>

<script type="text/javascript" src="<?php echo G_STATIC_URL; ?>/admin/js/goods/index.js?v=<?php echo G_VERSION_BUILD; ?>" ></script>

<?php TPL::output('admin/global/footer.tpl.htm'); ?>